package com.itheima.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.mapper.NursingPlanMapper;
import com.itheima.pojo.NursingPlan;
import com.itheima.pojo.PageResult;
import com.itheima.queryParams.NursingPlanDto;
import com.itheima.service.NursingPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NursingPlanServiceImpl extends ServiceImpl<NursingPlanMapper, NursingPlan> implements NursingPlanService {

    @Autowired
    private NursingPlanMapper nursingPlanMapper;

    @Override
    public PageResult findAll(NursingPlanDto dto) {
        PageHelper.startPage(dto.getPage(),dto.getPageSize());
        List<NursingPlan> list = nursingPlanMapper.findAll(dto);
        Page<NursingPlan> nursingPlans = (Page<NursingPlan>) list;
        return new PageResult(nursingPlans.getTotal(),nursingPlans.getResult());
    }
}
